package com.brickworkers.codemaker.service;

import java.io.File;
import java.io.IOException;

import com.brickworkers.codemaker.utils.PathUtil;

import static com.brickworkers.codemaker.utils.MakerconfResource.rb;
import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Version;

public class FileOutPutFactory {
	
	private static volatile Configuration cfg;
	
	public static Configuration getConf() throws IOException{
		File file = new File(PathUtil.path + rb.getString("temp.path").replace(".", "/"));
		if(cfg == null){
			synchronized (FileOutPutFactory.class) {
				cfg = new Configuration(new Version(2, 3, 0));
				cfg.setDirectoryForTemplateLoading(file);
				cfg.setObjectWrapper(new DefaultObjectWrapper(new Version(2, 3, 0)));
			}
		}
		return cfg;
	}

	
	
}
